package com.noahplat.sms.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Date;

/**
 * 作者：李景星
 * 描述：用户实体类
 * 时间：2020-10-31
 */
@Data
@Table(name = "tb_sysmsg")
public class Sms implements Serializable {

    @Id
    private Long id;    //主键ID

    @NotEmpty(message = "手机号不能为空")
    @Length(max = 32, message = "手机号长度错误")
    private String phone;   //发送手机号

    @NotEmpty(message = "发送内容不能为空")
    @Length(max = 1024, message = "内容长度错误")
    private String content; //发送内容

    @NotEmpty(message = "发送时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date sendtime; //发送时间

    @NotEmpty(message = "删除标志不能为空")
    @Length(max = 1, message = "删除标志长度错误")
    private String del = "N"; //是否删除 是否删除：Y-已经删除；N-未删除

    public Sms(@NotEmpty(message = "手机号不能为空") @Length(max = 32, message = "手机号长度错误") String phone, @NotEmpty(message = "发送内容不能为空") @Length(max = 1024, message = "内容长度错误") String content, @NotEmpty(message = "发送时间不能为空") Date sendtime) {
        this.phone = phone;
        this.content = content;
        this.sendtime = sendtime;
    }
}
